package pe.edu.pucp.Seguridad.Vista;

import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import pe.edu.pucp.Modelo.Aeropuerto;
import pe.edu.pucp.Modelo.Ciudad;
import pe.edu.pucp.Modelo.Continente;
import pe.edu.pucp.Modelo.Pais;
import pe.edu.pucp.Modelo.Perfil;
import pe.edu.pucp.Modelo.TipoCorreo;
import pe.edu.pucp.Modelo.TipoDocumento;
import pe.edu.pucp.Modelo.Usuario;
import pe.edu.pucp.Util.ValHelper;

public class UsuarioGUI extends javax.swing.JDialog {
    private ArrayList<Pais> lstPais;
    private ArrayList<Continente> lstContinente;
    private ArrayList<Ciudad> lstCiudad;
    private ArrayList<Aeropuerto> lstAeropuerto;
    private ArrayList<TipoDocumento> lstTipoDoc;
    private ArrayList<TipoCorreo> lstCorreo;
    private ArrayList<Perfil> lstPerfil;
          
    public UsuarioGUI(javax.swing.JFrame parent, boolean modal) {
        super(parent,modal);
        initComponents();
        setLocationRelativeTo(null);
    }      
    
    public void setEstadoGuardar(String msn, String titulo){        
        btnGuardar.setToolTipText(msn);
        this.setTitle("SIGEPA - "+titulo);
    }    
    
    
    public void setFormUsuario(Usuario u){
        if (u!=null){
            
            txtNombre.setText(u.getNombre());
            txtApMaterno.setText(u.getApmaterno());
            txtApPaterno.setText(u.getAppaterno());
            txtCorreo.setText(u.getCorreo());
            txtDireccion.setText(u.getDireccion());
            txtDoc.setText(u.getDocumento());
            txtTelefono.setText(u.getTelefono());   
            spnFallo.setValue(u.getMaxfallo());
            
            for (int i = 0; i < lstContinente.size(); i++){
                if (lstContinente.get(i).getIdcontinente()==u.getAeropuerto().getCiudad().getPais().getContinente().getIdcontinente())
                    this.cmbContinente.setSelectedIndex(i);  
            }
           
            for (int i = 0; i < lstPais.size(); i++){
                if (lstPais.get(i).getIdpais()==u.getAeropuerto().getCiudad().getPais().getIdpais())
                    this.cmbPais.setSelectedIndex(i);  
            }            
            for (int i = 0; i < lstCiudad.size(); i++){
                if (lstCiudad.get(i).getIdciudad()==u.getAeropuerto().getCiudad().getIdciudad())
                    this.cmbCiudad.setSelectedIndex(i);  
            }            
            for (int i = 0; i < lstAeropuerto.size(); i++){
                if (lstAeropuerto.get(i).getIdaeropuerto()==u.getAeropuerto().getIdaeropuerto())
                    this.cmbAeropuerto.setSelectedIndex(i);  
            }                        
            for (int i = 0; i < lstTipoDoc.size(); i++){
                if (lstTipoDoc.get(i).getIdtipodoc()==u.getTipoDocumento().getIdtipodoc())
                    this.cmbTipoDoc.setSelectedIndex(i);  
            }
            for (int i = 0; i < lstCorreo.size(); i++){
                if (lstCorreo.get(i).getIdtipocorreo()==u.getTipoCorreo().getIdtipocorreo())
                    this.cmbCorreo.setSelectedIndex(i);  
            }                         
            for (int i = 0; i < lstPerfil.size(); i++){
                if (lstPerfil.get(i).getIdperfil()==u.getPerfil().getIdperfil())
                    this.cmbPerfil.setSelectedIndex(i);  
            }             
        }
    }
      
    public int getCiudad(){ return cmbCiudad.getSelectedIndex(); }    

    public int getMaxFallo(){ return Integer.parseInt(spnFallo.getValue().toString()); }      
    
    public int getContinente(){ return cmbContinente.getSelectedIndex(); }        
    
    public int getPais(){ return cmbPais.getSelectedIndex(); }    
    
    public int getAeropuerto(){ return cmbAeropuerto.getSelectedIndex(); }   

    public int getTipoDoc(){ return cmbTipoDoc.getSelectedIndex(); }             
    
    public String getNombre(){ return txtNombre.getText().trim(); }      
    
    public String getApPaterno(){ return txtApPaterno.getText().trim(); }      
    
    public String getApMaterno(){ return txtApMaterno.getText().trim(); }  
    
    public String getNumDoc(){ return txtDoc.getText().trim(); }      

    public String getTelefono(){ return txtTelefono.getText().trim(); }      

    public String getDireccion(){ return txtDireccion.getText().trim(); }     
    
    public String getCorreo(){ return txtCorreo.getText().trim(); }

    public int getTipoCorreo(){ return cmbCorreo.getSelectedIndex(); }       

    public int getPerfil(){ return cmbPerfil.getSelectedIndex(); }     
       
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtCorreo = new javax.swing.JTextField();
        txtTelefono = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        cmbCiudad = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        cmbPais = new javax.swing.JComboBox();
        txtDoc = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        cmbTipoDoc = new javax.swing.JComboBox();
        txtApPaterno = new javax.swing.JTextField();
        txtNombre = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cmbCorreo = new javax.swing.JComboBox();
        cmbContinente = new javax.swing.JComboBox();
        btnGuardar = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        cmbPerfil = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtApMaterno = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        spnFallo = new javax.swing.JSpinner();
        cmbAeropuerto = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Ubuntu", 0, 15))); // NOI18N

        txtCorreo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtCorreoKeyTyped(evt);
            }
        });

        txtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyTyped(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel4.setForeground(java.awt.Color.gray);
        jLabel4.setText("Correo");

        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDireccionKeyTyped(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel11.setForeground(java.awt.Color.gray);
        jLabel11.setText("Continente");

        txtDoc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDocKeyTyped(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel6.setForeground(java.awt.Color.gray);
        jLabel6.setText("Documento");

        txtApPaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApPaternoKeyTyped(evt);
            }
        });

        txtNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombreKeyTyped(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setForeground(java.awt.Color.gray);
        jLabel1.setText("Nombre");

        jLabel3.setForeground(java.awt.Color.gray);
        jLabel3.setText("Telefono");

        jLabel5.setForeground(java.awt.Color.gray);
        jLabel5.setText("Direccion");

        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/checkmark.png"))); // NOI18N
        btnGuardar.setToolTipText("");

        btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/refresh.png"))); // NOI18N
        btnLimpiar.setToolTipText("Limpiar");

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/delete.png"))); // NOI18N
        btnCancelar.setToolTipText("Cancelar");

        jLabel12.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel12.setForeground(java.awt.Color.gray);
        jLabel12.setText("Perfil");

        jLabel8.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel8.setForeground(java.awt.Color.gray);
        jLabel8.setText("Apellido Paterno");

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel2.setForeground(java.awt.Color.gray);
        jLabel2.setText("Apellidos Materno");

        txtApMaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApMaternoKeyTyped(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel13.setForeground(java.awt.Color.gray);
        jLabel13.setText("Ciudad");

        jLabel14.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel14.setForeground(java.awt.Color.gray);
        jLabel14.setText("Pais");

        jLabel7.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel7.setForeground(java.awt.Color.gray);
        jLabel7.setText("Intentos de Acceso");

        spnFallo.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        jLabel15.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel15.setForeground(java.awt.Color.gray);
        jLabel15.setText("Aeropuerto");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel8)
                    .addComponent(jLabel2)
                    .addComponent(jLabel12)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel7))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spnFallo, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cmbCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 648, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(cmbTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(txtDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmbPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14)
                            .addComponent(jLabel11)
                            .addComponent(jLabel13)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cmbCiudad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbPais, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbContinente, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbAeropuerto, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtApMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel12)
                            .addComponent(cmbPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(cmbContinente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(cmbPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(cmbCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel15)
                            .addComponent(cmbAeropuerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(cmbTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(spnFallo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtNombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyTyped
        String car = txtNombre.getText();
        if(car.length()>=25) evt.consume();        
        ValHelper.soloTexto(evt);
    }//GEN-LAST:event_txtNombreKeyTyped

    private void txtApPaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApPaternoKeyTyped
        String car = txtApPaterno.getText();
        if(car.length()>=25) evt.consume();        
        ValHelper.soloTexto(evt);        
    }//GEN-LAST:event_txtApPaternoKeyTyped

    private void txtApMaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApMaternoKeyTyped
        String car = txtApMaterno.getText();
        if(car.length()>=25) evt.consume();        
        ValHelper.soloTexto(evt);       
    }//GEN-LAST:event_txtApMaternoKeyTyped

    private void txtDocKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDocKeyTyped
        String car = txtDoc.getText();
        if(car.length()>=8) evt.consume();        
        ValHelper.soloDigito(evt);  
    }//GEN-LAST:event_txtDocKeyTyped

    private void txtTelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyTyped
        String car = txtTelefono.getText();
        if(car.length()>=9) evt.consume();        
        ValHelper.soloDigito(evt); 
    }//GEN-LAST:event_txtTelefonoKeyTyped

    private void txtDireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyTyped
        String car = txtDireccion.getText();
        if(car.length()>=50) evt.consume();    
        ValHelper.soloDigitoTextoPuntuacion(evt);
    }//GEN-LAST:event_txtDireccionKeyTyped

    private void txtCorreoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCorreoKeyTyped
        String car = txtCorreo.getText();
        if(car.length()>=20) evt.consume();        
        ValHelper.soloDigitoTextoPuntuacion(evt);
    }//GEN-LAST:event_txtCorreoKeyTyped

    public void LimpiarDatos(){
        txtNombre.setText("");
        txtApMaterno.setText("");
        txtApPaterno.setText("");
        txtCorreo.setText("");
        txtDireccion.setText("");
        txtDoc.setText("");
        txtTelefono.setText("");
        cmbContinente.setSelectedIndex(0);
        cmbPais.setSelectedIndex(0);        
        cmbCiudad.setSelectedIndex(0);
        cmbAeropuerto.setSelectedIndex(0);
        cmbTipoDoc.setSelectedIndex(0);
        cmbCorreo.setSelectedIndex(0);
        cmbPerfil.setSelectedItem(0);
        spnFallo.setValue(1);
    }
    
    public void addLimpiarListener(ActionListener ml){ this.btnLimpiar.addActionListener(ml); }
        
    public void addGuardarListener(ActionListener ml){ this.btnGuardar.addActionListener(ml); }
    
    public void addCancelarListener(ActionListener ml){ this.btnCancelar.addActionListener(ml); }     

    public void addCambiarContinente(ItemListener ml){ this.cmbContinente.addItemListener(ml); }     
    
    public void addCambiarPais(ItemListener ml){ this.cmbPais.addItemListener(ml); }         
    
    public void addCambiarCiudad(ItemListener ml){ this.cmbCiudad.addItemListener(ml); }         
    
    public void llenaComboPais(ArrayList<Pais> lista){
        cmbPais.removeAllItems();
        if(lista!=null){
            lstPais = lista;
            for (Pais c : lista){
                cmbPais.addItem(c.getDescripcion());
            }
        }
    }    

    public void llenaComboPerfil(ArrayList<Perfil> lista){
        if(lista!=null){
            lstPerfil = lista;
            for (Perfil c : lista){
                cmbPerfil.addItem(c.getDescripcion());
            }
        }
    }    
    
    public void llenaComboContinente(ArrayList<Continente> lista){       
        cmbContinente.removeAllItems();
        if(lista!=null){
            lstContinente = lista;
            for (Continente c : lista){
                cmbContinente.addItem(c.getDescripcion());
            }
        }
    }     
    
    public void llenaComboCiudad(ArrayList<Ciudad> lista){
        cmbCiudad.removeAllItems();
        if(lista!=null){
            lstCiudad = lista;
            for (Ciudad c : lista){
                cmbCiudad.addItem(c.getDescripcion());
            }
        }
    }       

    public void llenaComboAeropuerto(ArrayList<Aeropuerto> lista){
        cmbAeropuerto.removeAllItems();
        if(lista!=null){
            lstAeropuerto = lista;
            for (Aeropuerto c : lista){
                cmbAeropuerto.addItem(c.getDescripcion());
            }
        }
    }    
    
    public void llenaComboTipoDoc(ArrayList<TipoDocumento> lista){
        if(lista!=null){
            lstTipoDoc = lista;
            for (TipoDocumento c : lista){
                cmbTipoDoc.addItem(c.getDescripcion());
            }
        }
    }    
    
    public void llenaComboCorreo(ArrayList<TipoCorreo> lista){
        if(lista!=null){
            lstCorreo = lista;
            for (TipoCorreo c : lista){
                cmbCorreo.addItem(c.getExtension());
            }
        }
    }     
    
    
    
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JComboBox cmbAeropuerto;
    private javax.swing.JComboBox cmbCiudad;
    private javax.swing.JComboBox cmbContinente;
    private javax.swing.JComboBox cmbCorreo;
    private javax.swing.JComboBox cmbPais;
    private javax.swing.JComboBox cmbPerfil;
    private javax.swing.JComboBox cmbTipoDoc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSpinner spnFallo;
    private javax.swing.JTextField txtApMaterno;
    private javax.swing.JTextField txtApPaterno;
    private javax.swing.JTextField txtCorreo;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDoc;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}
